// 公共参数
const PROTOCOL = 'http'
// const HOST = '127.0.0.1'
const HOST = '192.168.35.17'
const PORT = '3005'
const baseURL = `${PROTOCOL}://${HOST}:${PORT}`
import router from "@/router"
import axios from "axios"
// post请求
export const postFunc = (url, data = {}, option = {
    headers: "application/x-www-form-urlencoded"
}) => {
    return axios.post(`${baseURL}${url}`, data, option)
        .then(
            response => {
                return response.data;
            }
        )
}
// get请求
export const getFunc = (url, data = {}) => {
    return axios.get(`${baseURL}${url}`, {
            params: data
        })
        .then(
            response => {
                return response.data;
            }
        )
}
// 登陆
export const loginFunc = (url, data = {}, option = {
    headers: "application/x-www-form-urlencoded"
}) => {
    return axios.post(`${baseURL}${url}`, data, option)
        .then(
            response => {
                return response.data;
            }
        )
}
// 注册
export const registerFunc = (url, data = {}, option = {
    headers: "application/x-www-form-urlencoded"
}) => {
    return axios.post(`${baseURL}${url}`, data, option)
        .then(
            response => {
                return response.data;
            }
        )
}
// 留言
export const commentFunc = (url, data = {}, option = {
    headers: "application/x-www-form-urlencoded"
}) => {
    return axios.post(`${baseURL}${url}`, data, option)
        .then(
            response => {
                return response.data;
            }
        )
}
// 查看是哪个人留言
export const mycommentFunc = (url, data = {}, option = {
    headers: "application/x-www-form-urlencoded"
}) => {
    return axios.post(`${baseURL}${url}`, data, option)
        .then(
            response => {
                return response.data;
            }
        )
}
// 删除个人留言
export const removecommentFunc = (url, data = {}, option = {
    headers: "application/x-www-form-urlencoded"
}) => {
    return axios.post(`${baseURL}${url}`, data, option)
        .then(
            response => {
                return response.data;
            }
        )
}





// 添加评论
export const addevaluateFunc = (url, data = {}, option = {
    headers: "application/x-www-form-urlencoded"
}) => {
    return axios.post(`${baseURL}${url}`, data, option)
        .then(
            response => {
                return response.data;
            }
        )
}
// 获取评论列表
export const newsevaluateFunc = (url, data = {}, option = {
    headers: "application/x-www-form-urlencoded"
}) => {
    return axios.post(`${baseURL}${url}`, data, option)
        .then(
            response => {
                return response.data;
            }
        )
}
// 删除评论
export const removeevaluateFunc = (url, data = {}, option = {
    headers: "application/x-www-form-urlencoded"
}) => {
    return axios.post(`${baseURL}${url}`, data, option)
        .then(
            response => {
                return response.data;
            }
        )
}




// 获取用户信息
export const getDetail = (url, data = {}, option = {
    headers: "application/x-www-form-urlencoded"
}) => {
    return axios.post(`${baseURL}${url}`, data, option)
        .then(
            response => {
                return response.data;
            }
        )
}
// 发送验证码
export const sendEmailFunc = (url, data = {}) => {
    return axios.get(`${baseURL}${url}`, {
            params: data
        })
        .then(
            response => {
                return response.data;
            }
        )
}
// 获取广告列表
export const getAdvertList = (url) => {
    return axios.get(`${baseURL}${url}`)
        .then(
            response => {
                return response.data;
            }
        )
}
// 获取新闻资讯列表
export const getNewsList = (url) => {
    return axios.get(`${baseURL}${url}`)
        .then(
            response => {
                return response.data;
            }
        )
}

// 获取产品列表
export const getProductsList = (url) => {
    return axios.get(`${baseURL}${url}`)
        .then(
            response => {
                return response.data;
            }
        )
}

// 获取关于我们列表
export const getAboutList = (url) => {
    return axios.get(`${baseURL}${url}`)
        .then(
            response => {
                return response.data;
            }
        )
}

// 获取厂区环境列表
export const getEnvironment = (url) => {
    return axios.get(`${baseURL}${url}`)
        .then(
            response => {
                return response.data;
            }
        )
}

// 获取搜索列表
export const getSearchList = (url, data = {}, option = {
    headers: "application/x-www-form-urlencoded"
}) => {
    return axios.post(`${baseURL}${url}`, data, option)
        .then(
            response => {
                return response.data;
            }
        )
}

// 获取搜索详情
export const getSearchDeatil = (url, data = {}, option = {
    headers: "application/x-www-form-urlencoded"
}) => {
    return axios.post(`${baseURL}${url}`, data, option)
        .then(
            response => {
                return response.data;
            }
        )
}

// 上传图片的方法
export const uploadFunc = (url, data = {}, option = {
    headers: "application/x-www-form-urlencoded"
}) => {
    return axios.post(`${baseURL}${url}`, data, option)
        .then(
            response => {
                return response.data;
            }
        )
}

// 删除轮播图
export const deletebannerFunc = (url, data = {}, option = {
    headers: "application/x-www-form-urlencoded"
}) => {
    return axios.post(`${baseURL}${url}`, data, option)
        .then(
            response => {
                return response.data;
            }
        )
}

// 上传新闻
export const uploadnewsFunc = (url, data = {}, option = {
    headers: "application/x-www-form-urlencoded"
}) => {
    return axios.post(`${baseURL}${url}`, data, option)
        .then(
            response => {
                return response.data;
            }
        )
}

// 删除新闻
export const deletenewsFunc = (url, data = {}, option = {
    headers: "application/x-www-form-urlencoded"
}) => {
    return axios.post(`${baseURL}${url}`, data, option)
        .then(
            response => {
                return response.data;
            }
        )
}
// 修改新闻
export const updatenewsFunc = (url, data = {}, option = {
    headers: "application/x-www-form-urlencoded"
}) => {
    return axios.post(`${baseURL}${url}`, data, option)
        .then(
            response => {
                return response.data;
            }
        )
}

// 删除产品
export const deleteproductFunc = (url, data = {}, option = {
    headers: "application/x-www-form-urlencoded"
}) => {
    return axios.post(`${baseURL}${url}`, data, option)
        .then(
            response => {
                return response.data;
            }
        )
}

// 上传产品
export const uploadproductFunc = (url, data = {}, option = {
    headers: "application/x-www-form-urlencoded"
}) => {
    return axios.post(`${baseURL}${url}`, data, option)
        .then(
            response => {
                return response.data;
            }
        )
}

// 获取用户列表
export const getuser = (url) => {
    return axios.get(`${baseURL}${url}`)
        .then(
            response => {
                return response.data;
            }
        )
}

// 删除用户
export const deleteuserFunc = (url, data = {}, option = {
    headers: "application/x-www-form-urlencoded"
}) => {
    return axios.post(`${baseURL}${url}`, data, option)
        .then(
            response => {
                return response.data;
            }
        )
}

// 添加用户
export const adduserFunc = (url, data = {}, option = {
    headers: "application/x-www-form-urlencoded"
}) => {
    return axios.post(`${baseURL}${url}`, data, option)
        .then(
            response => {
                return response.data;
            }
        )
}

// 获取留言列表
export const getcommentsFunc = (url) => {
    return axios.get(`${baseURL}${url}`)
        .then(
            response => {
                return response.data;
            }
        )
}

// 删除留言
export const deletecommentsFunc = (url, data = {}, option = {
    headers: "application/x-www-form-urlencoded"
}) => {
    return axios.post(`${baseURL}${url}`, data, option)
        .then(
            response => {
                return response.data;
            }
        )
}

// 管理员登录
export const adminloginFunc = (url, data = {}, option = {headers: "application/x-www-form-urlencoded"}) => {
    return axios.post(`${baseURL}${url}`, data, option)
    .then(
        response=> {
            return response.data;
        }
    )
}